<template>
	<view class="default-background">
		<view class="feedback-list-page">
			<scroll-view>
				<view class="feedback-item" v-for="feedback in this.feedbackList" @click="getDetail(feedback.id)">
					<view class="title limit-one-line">{{feedback.title}}</view>
					<view class="content limit-two-line">{{feedback.content}}</view>
				</view>
				<view class="page-bottom"></view>
			</scroll-view>
			<view class="btn-group">
				<view class="confirmBtn button" @click="toSubmit()">提交反馈</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				limit: 6,
				feedbackList: []
			};
		},
		methods: {
			getFeedbackList() {
				this.$request.request({
					url: "/feedback/list",
					method: "GET",
					data: {
						page: this.page,
						limit: this.limit
					}
				}).then(res=>{
					if (res.code == 200) {
						if (res.data.length <= 0) {
							uni.showToast({
								title: "没有更多数据了~",
								icon: "none"
							})
							return;
						} else {
							this.feedbackList = this.feedbackList.concat(res.data)
						}
					} else {
						uni.navigateTo({
							url: "../user/login"
						})
					}
				})
			},
			getDetail(id) {
				uni.navigateTo({
					url: "./detail?id=" + id
				})
			},
			toSubmit() {
				uni.navigateTo({
					url: "./submit"
				})
			}
		},
		onLoad() {
			this.getFeedbackList();
		},
		onPullDownRefresh() {
		  this.page = 1;
			this.feedbackList = [];
			this.getFeedbackList();
			uni.stopPullDownRefresh();
	  },
		async onReachBottom() {
			this.page += 1;
			this.getFeedbackList();
		}
	}
</script>

<style lang="scss">
	.feedback-list-page {
		
		.feedback-item {
			background-color: #FFFFFF;
			padding: 20rpx;
			border-bottom: 3rpx solid #F2F1F6;
			border-radius: 20rpx;
				
			.title {
				font-size: 20px;
			}
			
			.content {
				margin-top: 30rpx;
				font-size: 16px;
				color: #999999;
			}
		}
		
	}
</style>
